//
//  TFTimeSuperView.swift
//  TalkfunSDKDemo
//
//  Created by 莫瑞权 on 2022/5/3.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TFTimeSuperView: UIView {
    @objc public var proportion:CGFloat = 0 //比例

    override func draw(_ rect: CGRect) {
        // Drawing code
        let ctx = UIGraphicsGetCurrentContext()//获取上下文

     
         //最外面的
         let center = CGPoint(x: self.frame.size.width/2, y: self.frame.size.width/2)  //设置圆心位置
        let radius = self.frame.size.width/2;  //设置半径
        let startA = -M_PI_2;  //圆起点位置
        let endA = -M_PI_2 + M_PI * 2 * 1;  //圆终点位置 self.proportion

        let path = UIBezierPath.init(arcCenter: center, radius: radius, startAngle: startA, endAngle: endA, clockwise: true)
         
        
        ctx?.setLineWidth(10)
       //设置线条宽度

        UIColor(red: 56/255.0, green: 55/255.0, blue: 60/255.0, alpha: 1).setStroke()
         //设置描边颜色
        ctx?.setAlpha(0.7)
      
        ctx?.addPath(path.cgPath)  //把路径添加到上下文

        ctx?.strokePath() //渲染
          
        
            //  最外面的
        let center1 = center  //设置圆心位置
        let radius1 = self.frame.size.width/2;  //设置半径
        let startA1 = -M_PI_2   //圆起点位置
        let endA1   = -M_PI_2+M_PI*2*self.proportion  //圆终点位置
        
        let path1 = UIBezierPath.init(arcCenter: center1, radius: radius1, startAngle: startA1, endAngle: endA1, clockwise: true)
        
        ctx?.setLineWidth(10) //设置线条宽度
        UIColor(red: 77/255.0, green: 154/255.0, blue: 255/255.0, alpha: 1).setStroke()  //设置描边颜色
           
        ctx?.addPath(path1.cgPath) //把路径添加到上下文
        ctx?.strokePath() //渲染
        
           
        
    }
  

}
